/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.Beans;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Bone
 */
@Entity
@Table(name = "nfe_fatura")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "NfeFatura.findAll", query = "SELECT n FROM NfeFatura n")})
public class NfeFatura implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer id;
    @Column(length = 60)
    private String numero;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "VALOR_ORIGINAL", precision = 18, scale = 6)
    private BigDecimal valorOriginal;
    @Column(name = "VALOR_DESCONTO", precision = 18, scale = 6)
    private BigDecimal valorDesconto;
    @Column(name = "VALOR_LIQUIDO", precision = 18, scale = 6)
    private BigDecimal valorLiquido;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idNfeFatura")
    private List<NfeDuplicata> nfeDuplicataList;
    @JoinColumn(name = "ID_NFE_CABECALHO", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private NfeCabecalho idNfeCabecalho;

    public NfeFatura() {
    }

    public NfeFatura(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public BigDecimal getValorOriginal() {
        return valorOriginal;
    }

    public void setValorOriginal(BigDecimal valorOriginal) {
        this.valorOriginal = valorOriginal;
    }

    public BigDecimal getValorDesconto() {
        return valorDesconto;
    }

    public void setValorDesconto(BigDecimal valorDesconto) {
        this.valorDesconto = valorDesconto;
    }

    public BigDecimal getValorLiquido() {
        return valorLiquido;
    }

    public void setValorLiquido(BigDecimal valorLiquido) {
        this.valorLiquido = valorLiquido;
    }

    @XmlTransient
    public List<NfeDuplicata> getNfeDuplicataList() {
        return nfeDuplicataList;
    }

    public void setNfeDuplicataList(List<NfeDuplicata> nfeDuplicataList) {
        this.nfeDuplicataList = nfeDuplicataList;
    }

    public NfeCabecalho getIdNfeCabecalho() {
        return idNfeCabecalho;
    }

    public void setIdNfeCabecalho(NfeCabecalho idNfeCabecalho) {
        this.idNfeCabecalho = idNfeCabecalho;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof NfeFatura)) {
            return false;
        }
        NfeFatura other = (NfeFatura) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bs.Beans.NfeFatura[ id=" + id + " ]";
    }
    
}
